﻿Namespace EIBData.DPT
    Public NotInheritable Class EIBDataDPT_4_001
        Inherits EIBDataDPT_4_Base

        Private _value As Char = Nothing

        Sub New(data As Byte())
            MyBase.New(data)

            If _valueBase > 127 Then Throw New EIB.Exceptions.EIBDataDecodeException("")

            _value = System.Text.Encoding.ASCII.GetChars(New Byte() {_valueBase})(0)
        End Sub

        Sub New(value As Char)
            MyBase.New(System.Text.Encoding.ASCII.GetBytes(New Char() {value})(0))

            _value = value
        End Sub


        Public Overrides Function ToInfoList() As List(Of EIB.InfoBase)
            Dim list As New List(Of EIB.InfoBase)

            list.Add(New EIB.Info("Type", DPT_Name))
            list.Add(New EIB.Info("Character", _value))

            Return list
        End Function

        Public Shared Shadows ReadOnly Property DPT_Name As String
            Get
                Return "DPT_Char_ASCII"
            End Get
        End Property

        Public Shared Shadows ReadOnly Property DPT_Number As String
            Get
                Return "4.001"
            End Get
        End Property

        Public Overrides Function ToString() As String
            Return _value
        End Function
    End Class
End Namespace